package com.chixing.service.impl;

import com.chixing.entity.Coupon;
import com.chixing.entity.UserCoupon;
import com.chixing.entity.vo.CouponDetailVO;
import com.chixing.mapper.CouponMapper;
import com.chixing.service.ICouponService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chixing.service.IUserCouponService;
import com.chixing.util.Result;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liwenjing
 * @since 2025-10-07
 */
@Service
public class CouponServiceImpl  implements ICouponService {

    @Autowired
    private  CouponMapper couponMapper;
    @Override
    public Result getById(Integer id) {
        System.out.println(id);
        Coupon coupon =  couponMapper.selectById(id);
        if (coupon != null)
            return Result.getSuccess(coupon);
        return Result.getFail(null);
    }

    @Override
    public Result getByStatus(Integer userId, Integer couponStatus) {
        List<CouponDetailVO> couponDetailVOList = couponMapper.selectAllCoupon(userId,couponStatus);
        if (couponDetailVOList != null && couponDetailVOList.size() > 0){
            return Result.getSuccess(couponDetailVOList);

        }

        return Result.getFail(null);

    }
}

